#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, m, a[502], b[502], a1[502], a2[502], t1, t2;
double res = 1e308;

void dfs(int i) {
	if (i == n + 1) {
		int ya[n + 1], yb[n + 1];
		for (int i = 1; i <= t1; ++i) ya[i] = a1[i];
		for (int i = 1; i <= t2; ++i) yb[i] = a2[i];
		sort(ya + 1, ya + t1 + 1);
		sort(yb + 1, yb + t2 + 1);
		double ans = 1e300;
		for (int pe = 0; pe <= min(m, t1); ++pe) { // 需要额外的 pe 个人
			if (m - pe > t2) continue;
			double sum = 0;
			for (int i = 1; i <= pe; ++i) {
				sum += (double)ya[i] / i;
			}
			for (int i = 1; i <= m - pe; ++i) {
				sum += (double)yb[i] / (pe + 1);
			}
			ans = min(ans, sum);
		}
		res = min(res, ans); 
		return;
	}
	if (b[i] != -1) {
		a1[++t1] = b[i];
		dfs(i + 1);
		--t1;
	}
	a2[++t2] = a[i];
	dfs(i + 1);
	--t2;
}

signed main() {

	freopen("talk.in", "r", stdin); freopen("talk.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	bool flg1 = 1;
	bool flg2 = 1;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
		flg1 &= (b[i] == -1);
		flg2 &= (a[i] == b[i] || b[i] == -1);
	}
	if (flg1) {
		sort(a + 1, a + n + 1);
		int sum = 0;
		for (int i = 1; i <= m; ++i) {
			sum += a[i];
		}
		cout << sum << "\n";
	} else if (flg2 && 0) {
		for (int i = 1; i <= n; ++i) {
			if (b[i] == a[i]) a1[++t1] = a[i];
			else a2[++t2] = a[i];
		}
		sort(a1 + 1, a1 + t1 + 1);
		sort(a2 + 1, a2 + t2 + 1);
		double ans = 1e300;
		for (int pe = 0; pe <= min(m, t1); ++pe) { // 需要额外的 pe 个人
			if (m - pe > t2) continue;
			double sum = 0;
			for (int i = 1; i <= pe; ++i) {
				sum += (double)a1[i] / i;
			}
			for (int i = 1; i <= m - pe; ++i) {
				sum += (double)a2[i] / (pe + 1);
			}
			ans = min(ans, sum);
		}
		printf("%.10lf\n", ans);
	} else if (n <= 20) {
		dfs(1);
		printf("%.10lf\n", res);
	}
	return 0;
}
